﻿@model PagedList<Orange.Mvc4App.Models.Charge>
@{
    ViewBag.Title = "水电费一览";
    string itemType = "所有";
    switch ((string)ViewBag.Type) {
        case "All":
            itemType = "所有";
            break;
        case "Water":
            itemType = "水费";
            break;
        case "Elec":
            itemType = "电费";
            break;
    }
}
@section css{
    <style>
        .ddl
        {
            width: 100px;
        }
    </style>
}
<h2>
    水电费一览</h2>
<div class="toolbar">
</div>
<div class="hidden">
    @Html.Hidden("hidWater", @Url.Action("Water"))
    @Html.Hidden("hidElec", @Url.Action("Elec"))
</div>
<div class="upload">
    @using (Html.BeginForm("Index", "Charge",
        FormMethod.Post, new { enctype = "multipart/form-data" })) {
        <input type="file" name="file" id="file" value="选择" />
        <input type="submit" value="导入单据" />
    }
</div>
@Html.DropDownList("ChargeItemType", Content.GetItemType(itemType), "--请选择--", new { @class = "ddl" })
<div id="list">
    <p class="message">
        @if (@ViewBag.Msg != null) {
            <img src="../../Content/images/icon-info.gif" alt="提示" />@ViewBag.Msg
        }
    </p>
    @if (Model != null && Model.PageCount > 0) {
        <table class="list">
            <tr>
                <th style="width: 180px;">
                    用量日期
                </th>
                <th>
                    类型
                </th>
                <th>
                    用量
                </th>
                <th>
                    金额
                </th>
            </tr>
            @foreach (var item in Model) {
                <tr>
                    <td>
                        @item.Date.ToString("yyyy-MM-dd")
                    </td>
                    <td>
                        @item.Type
                    </td>
                    <td>
                        @item.Amount
                    </td>
                    <td>
                        @item.Price
                    </td>
                </tr>
            }
        </table>
        <nav class="center">
            @Html.PageLinks(Model.PageCount, Model.PageIndex, i => Url.Action(ViewBag.Action, new { pageIndex = i }))
        </nav>
    } else {
        @:温馨提示: 没有数据哦
    }
</div>
@section script{
    <script type="text/javascript">
        $().ready(function () {
            $(".ddl").change(function () {
                //alert($(this).val());
                switch ($(this).val()) {
                    case "水费":
                        //location.href = $("#hidWater").val();
                        location.href = "/Charge/Water";
                        break;
                    case "电费":
                        //location.href = $("#hidElec").val();
                        location.href = "/Charge/Elec"
                        break;
                    default:
                        location.href = "/Charge";
                        break;
                }
            });
        });
    </script>
}
